﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <!-- xsd /c /l:cs ConfigBuilder.xsd /n:PBnD.MSBuild.Configuration.Brokers -->
  <xs:element name="ConfigBuilder">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="ConfigEnvironments">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="env">
                <xs:complexType>
                  <xs:attribute name="id" type="xs:string" use="required" />
                  <xs:attribute name="required" type="xs:boolean" use="optional" />
                  <xs:attribute name="outputFileName" type="xs:string" use="optional" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="defaultEnv" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
        <xs:element name="CommonConfigSections">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="CommonConfigSection">
                <xs:complexType>
                  <xs:attribute name="file" type="xs:string" use="required" />
                  <xs:attribute name="xpath" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
          <xs:unique name="Unique_CommonConfigSectionFile">
            <xs:selector xpath="./CommonConfigSection"/>
            <xs:field xpath="@file"/>
          </xs:unique>
        </xs:element>
        <xs:element name="ConfigSettings">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="ConfigSetting">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="value">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute name="env" type="xs:string" use="required" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="name" type="xs:string" use="required" />
                </xs:complexType>
                <xs:unique name="Unique_Value_env">
                  <xs:selector xpath="./value"/>
                  <xs:field xpath="@env"/>
                </xs:unique>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:key name="envID">
      <xs:selector xpath="./ConfigEnvironments/env"/>
      <xs:field xpath="@id"/>
    </xs:key>
    <xs:keyref name="envIDref" refer="envID">
      <xs:selector xpath="./ConfigSettings/ConfigSetting/value"/>
      <xs:field xpath="@env"/>
    </xs:keyref>
    <xs:unique name="envID_Index">
      <xs:selector xpath="./ConfigEnvironments/env"/>
      <xs:field xpath="@id"/>
    </xs:unique>
  </xs:element>
</xs:schema>